<?php 
class FriendsList extends APIBase {
	
	public $tag = "FriendsList";
	
	public function before() {
		$this->initMysql();
		return true;
	}
	
	public function logic() {
		
		$host_uid = $this->uid;
		$sql = "SELECT player.* FROM friends, player WHERE friends.host_uid = $host_uid AND friends.fri_uid = player.id";
		$result = $this->mysql->query($sql);
		if ($result)
		{
			while ($row = mysql_fetch_assoc($result)){
				$rows[] = $row;
			}
		}
		$friendslist = array();
		$now = time();
		foreach ($rows as $r)
		{
			$r1 = array();
			$r1['uid'] = (int) $r['id'];
			$r1['name'] = (string) $r['name'];
			$r1['sex'] = (int) $r['sex'];
			$r1['money'] = (int) $r['money'];											
			$r1["avater_url"] = (string) $r['avater_url'];
			$r1["is_online"] = 1;
			$friendslist[] = $r1;
		}		
		$this->returnData(array("friendslist" => $friendslist));
		     
	}
	
	public function after() {
		$this->deinitMysql();
	}
}
?>
